package com.amoby.main.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.amoby.base.common.Pager;
import com.amoby.main.entity.Cbabill;
import com.amoby.main.entity.SysUsers;
import com.amoby.main.mapper.CbabillMapper;
import com.amoby.main.service.CbaMgrService;

@Service("cbaMgrService")
public class CbaMgrServiceImpl implements CbaMgrService {

    @Autowired
    private CbabillMapper cbabillMapper;


    @Override
    public void loadCbabillPage(Pager pager) {
        pager.setResult(cbabillMapper.selectPageList(pager.getParamsMap()));
        pager.setTotalRecord(cbabillMapper.selectPageCount(pager.getParamsMap()));
    }

    @Override
    public Cbabill saveCbabill(Cbabill entity, SysUsers user) {
        if (entity.getId() == null) {
            throw new IllegalArgumentException("id must be not null");
        }

        entity.setUptime(new Date());
        if (cbabillMapper.updateCbabill(entity) != 1) {
            throw new RuntimeException("保存失败");
        }
        return entity;
    }

    @Override
    public List<Map<String, Object>> exportAll(Map<String, Object> map) {
        return cbabillMapper.exportAll(map);
    }

}
